<%- include header %>
<!-- 主题内容start -->
<div style="width: 60%;float: left">
    <form onsubmit="return checkueditor();" class="form-horizontal registerform" action="" method="post">
        <fieldset>
            <legend>添加活动(请先上传活动海报)</legend>

            <div>
                <div class="control-group">
                    <table>
                        <tr>
                            <td>
                                <label class="control-label"><span class="need" style="width:10px;">*</span> 活动名称</label>
                            </td>
                            <td>
                                <input type="text" class="inputxt"  name="theme" datatype="*3-18" errormsg="名称至少3个字符,最多18个字符！">
                            </td>
                            <td style="padding-top: 10px">
                                <span class="Validform_checktip"></span>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="control-group">
                    <table>
                        <tr>
                            <td>
                                <label class="control-label"><span class="need" style="width:10px;">*</span> 活动时间</label>
                            </td>
                            <td>
                                <!--<input type="text" name="start" id="start"  onclick="WdatePicker()">-->
                                <input type="text" class="inputxt"  name="activeDate" datatype="*6-30" onclick="WdatePicker()">
                            </td>
                            <td style="padding-top: 10px">
                                <span class="Validform_checktip"></span>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="control-group">
                    <table>
                        <tr>
                            <td>
                                <label class="control-label"><span class="need" style="width:10px;">*</span> 活动地点</label>
                            </td>
                            <td>
                                <input type="text" class="inputxt"  name="addr" datatype="*3-20" errormsg="请输入正确的地点！">
                            </td>
                            <td style="padding-top: 10px">
                                <span class="Validform_checktip"></span>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="control-group">
                    <table>
                        <tr>
                            <td>
                                <label class="control-label"><span class="need" style="width:10px;">*</span>&nbsp;&nbsp;&nbsp;&nbsp;主办方</label>
                            </td>
                            <td>
                                <input type="text" class="inputxt"  name="sponsor" datatype="*3-20" errormsg="主办方为3-20个字符！">
                            </td>
                            <td style="padding-top: 10px">
                                <span class="Validform_checktip"></span>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="control-group">
                    <table>
                        <tr>
                            <td>
                                <label class="control-label"><span class="need" style="width:10px;">*</span> 活动语言</label>
                            </td>
                            <td>
                                <select name="language" datatype="*" nullmsg="请选择语言！" errormsg="请选择语言！">
                                    <option value="">请选择</option>
                                    <% plateDatas.forEach(function(plateData,index){%>
                                    <option value="<%- plateData.platename%>"><%- plateData.platename%></option>
                                    <% })%>
                                </select>
                            </td>
                            <td style="padding-top: 10px">
                                <span class="Validform_checktip"></span>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="control-group">
                    <table>
                        <tr>
                            <td>
                                <label class="control-label"><span class="need" style="width:10px;">*</span> 活动费用</label>
                            </td>
                            <td>
                                <input type="text" class="inputxt"  name="cost" datatype="n1-4" errormsg=金额只能为0-1000的数字>
                            </td>
                            <td style="padding-top: 10px">
                                <span class="Validform_checktip"></span>
                            </td>
                        </tr>
                    </table>
                </div>

            </div>
            <div class="control-group">
                <label class="control-label" for="password">活动简介</label>
                <div class="controls">
                    <!--<textarea rows="10" style="width: 540px" id="k1" name=""></textarea>-->
                    <script id="container1" name="intro" type="text/plain"></script>

                </div>

            </div>

            <div class="control-group">
                <label class="control-label" for="password">详细信息</label>
                <div class="controls">
                    <!--<textarea rows="10" style="width: 540px" id="k1" name=""></textarea>-->
                    <script id="container" name="discribe" type="text/plain"></script>

                </div>

            </div>
            <div class="form-actions">
                <button type="submit" class="btn btn-primary ">提交</button>
            </div>
        </fieldset>
    </form>
</div>
<div style="width: 180px;height:230px;float: left;margin-left: 50px;border: 1px dotted #9f9d93;position: relative;margin-top: 80px">
    <img id="img_poster"  src="" style="width: 180px;height: 230px">
    <div class="circular" style="position: absolute;top:90px;left:25px;z-index:10;text-align:center;line-height: 20px;width:130px;height: 40px;background-color: #d77a03;">
        <h4 style="color: white;line-height: 20px">海报预览</b></h4>
    </div>
    <div class="file-box" style="margin-top: 20px">
        <form action="" id="uploadPoster" method="post" enctype="multipart/form-data">
            <input type='text' name='textfield' id='textfield' class='txt' style="margin-bottom: 0px"/>
            <input type='button' class='btn' value='浏览...' />
            <input type="file" name="file" class="file" id="fileToUpload" size="28" onchange="document.getElementById('textfield').value=this.value" />
            <input type="submit" name="submit" class="btn" value="上传" onclick="return ajaxFileUpload();"/>
        </form>

    </div>
</div>


<!-- 主题内容end -->
<%- include footer %>

<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('container',{
        initialFrameWidth:650,
        enableAutoSave:false,
        initialFrameHeight:171,
        saveInterval:60000
    });
    var ue = UE.getEditor('container1',{
        initialFrameWidth:650,
        enableAutoSave:false,
        initialFrameHeight:100,
        saveInterval:60000
    });
    function checkueditor(){

        //alert(UE.getEditor('container').getContent().replace(/[\s\r\n]/g,'').length)
        if(UE.getEditor('container').getContent().replace(/<.*?>/g,'').length==0){
            alert('详细信息不能为空，请重新输入')
            return false;
        }
        if(UE.getEditor('container1').getContent().replace(/<.*?>/g,'').length==0){
            alert('简介不能为空，请重新输入')
            return false;
        }
        return true;
    }
</script>
<script type="text/javascript">
    $(function(){
        //$(".registerform").Validform();  //就这一行代码！;

        $(".registerform").Validform({
            tiptype:2
        })


    })
    function ajaxFileUpload() {

        $.ajaxFileUpload({
            url : '/manager/uploadPoster',// servlet请求路径
            secureuri : false,
            fileElementId : 'fileToUpload',// 上传控件的id
            dataType:'text',
            success : function(data) {
                //alert(data);
                //alert(data.replace(/<.*?>/ig,''));

                if(data.indexOf('url')<0){
                    alert(data.replace(/<.*?>/ig,''));
                }
                eval("var jsobjjson="+data.replace(/<.*?>/ig,''));
                //alert(decodeURIComponent(jsobjjson.url))

                if(jsobjjson.state=='上传成功'){
                    //alert('111')
                    $("#img_poster").attr("src",decodeURIComponent(jsobjjson.url));
                }
            },
            error : function(data, status, e) {
                alert('上传出错');
            }
        })

        return false;

    }
</script>



